<template>
  <div ref="lineChart" class="lineChart" />
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'LineChart',
  mounted() {
    var myChart = echarts.init(this.$refs.lineChart)
    myChart.setOption({
      grid: {
        left: -10,
        right: -10,
        top: 0,
        bottom: 0
      },
      xAxis: {
        type: 'category',
        data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
      },
      yAxis: {
        show: false
      },
      series: [
        {
          data: [44, 126, 55, 88, 133, 99, 33, 113, 63, 98, 77, 123],
          type: 'line',
          smooth: true,
          // 去掉拐点线
          itemStyle: {
            opacity: 0
          },
          areaStyle: {
            color: {
              // 线性渐变
              type: 'linear',
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: 'blue' // 0% 处的颜色
                },
                {
                  offset: 1,
                  color: '#fff' // 100% 处的颜色
                }
              ],
              global: false // 缺省为 false
            }
          },
          // 设置折线的颜色
          lineStyle: {
            color: 'blue'
          }
        }
      ]
    })
  }
}
</script>

<style lang="scss" scoped>
.lineChart {
  width: 100%;
  height: 80px;
}
</style>